package com.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author 绛河
 * @date 2023/6/9
 * @apiNote
 */
@RestController
public class ConsumerController {


    private RestTemplate restTemplate = new RestTemplate();

    @GetMapping("/hello")
    public String hello() {
        // 调用服务提供者的/hello接口
        String url = "http://localhost:8080/hello";
        return restTemplate.getForObject(url, String.class);
    }
}
